package cn.bocai.pc.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.bocai.pc.dao.BcCollectMapper;
import cn.bocai.pc.model.BcCollect;
import cn.bocai.pc.service.BcCollectService;
@Service
public class BcCollectServiceImpl implements BcCollectService {
	@Autowired
	private BcCollectMapper BcCollectDao;
	
	/**
	 * 通过ajax请求将用户即时操作的收藏经常数据库保存
	 * @param BcCollect  对象
	 * @author chenaho
	 * @time 2015/07/07
	 */
	public int insert(BcCollect record) {
		int insert = BcCollectDao.insert(record);
		return insert;
	}
	
	/**
	 *先查询改表中是否存在改条信息，如果有就不存入没有就存储
	 * @param id 图片id
	 */
	public BcCollect queryEstimate(Map<String, Object> map){
		BcCollect queryEstimate =null;
		String periods = (String) map.get("periods");
		if("".equals(periods)||null==periods){
			queryEstimate = BcCollectDao.queryEstimateNull(map);
		}else{
			queryEstimate = BcCollectDao.queryEstimate(map);
		}	
		 
		 
		return queryEstimate;
	}
	
	/**
	 * 取消收藏
	 * @param par  传递过来的map值
	 * @author chenaho
	 * @time 2015/07/07
	 */
	public int deleteBcCollect(Map<String, String> par) {
		int deleteBcCollect = BcCollectDao.deleteBcCollect(par);
		return deleteBcCollect;
	}
	
	/**
	 * 查询出用户收藏的总行数
	 * @param id  传递过来的用户主键id
	 * @author chenaho
	 * @time 2015/07/07
	 */ 
	public int selectAllRow(String id){
		int selectAllRow = BcCollectDao.selectAllRow(id);
		return selectAllRow;
	}
	
	/**
	 * 查询出收藏的用户的数据
	 * @param id  传递过来的用户主键id
	 */ 
	public List<BcCollect> seleCollectAll(Map<String,Object> coll){
		List<BcCollect> seleCollectAll = BcCollectDao.seleCollectAll(coll);
		return seleCollectAll;
		
	}
	public int deleteByPrimaryKey(String id) {
		// TODO Auto-generated method stub
		return 0;
	}

	public int insertSelective(BcCollect record) {
		// TODO Auto-generated method stub
		return 0;
	}

	public BcCollect selectByPrimaryKey(String id) {
		// TODO Auto-generated method stub
		return null;
	}

	public int updateByPrimaryKeySelective(BcCollect record) {
		// TODO Auto-generated method stub
		return 0;
	}

	public int updateByPrimaryKeyWithBLOBs(BcCollect record) {
		// TODO Auto-generated method stub
		return 0;
	}

	public int updateByPrimaryKey(BcCollect record) {
		// TODO Auto-generated method stub
		return 0;
	}
	
	

}
